# Contributor: Brien Dieterle <briend@gmail.com>
# Contributor: Miloš Komarčević <miloskomarcevic@aim.com>

_realname=colour-science
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.4.2
pkgrel=1
pkgdesc="Python library for a multitude of colour science applications (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64')
url='https://www.colour-science.org'
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python-imageio"
         "${MINGW_PACKAGE_PREFIX}-python-numpy"
         "${MINGW_PACKAGE_PREFIX}-python-scipy"
         "${MINGW_PACKAGE_PREFIX}-python-typing_extensions")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-poetry-core")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-matplotlib"
            "${MINGW_PACKAGE_PREFIX}-python-networkx"
            "${MINGW_PACKAGE_PREFIX}-python-pandas"
            "${MINGW_PACKAGE_PREFIX}-python-tqdm"
            "${MINGW_PACKAGE_PREFIX}-python-trimesh")
conflicts=("${MINGW_PACKAGE_PREFIX}-python-${_realname//-science/}")
options=('!strip')
source=("${_realname//-science/}-${pkgver}.tar.gz"::"https://github.com/${_realname}/${_realname//-science/}/archive/v${pkgver}.tar.gz")
sha256sums=('f98e35206d5116f42ffba519036ce58e55e2a29c5e9eb8875bcbc2faf5bad29a')

prepare() {
  cd "${srcdir}/${_realname//-science/}-${pkgver}"
}

build() {
  cd "${srcdir}"
  cp -r "${_realname//-science/}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
